package cloud.maque.sso.server.ExceptionHandler;

import cloud.maque.common.core.exceptions.FlushException;
import cn.dev33.satoken.util.SaResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public SaResult handlerException(Exception e) {
        e.printStackTrace();
        return SaResult.error(e.getMessage());
    }

    /**
     * 直接把Flush推到前端的
     *
     * @param e
     * @return
     */
    @ExceptionHandler(FlushException.class)
    public SaResult handlerFlushException(FlushException e) {
        return SaResult.error("显示验证码").setCode(e.getCode()).setData(e.getMessage());
    }
}
